<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>

<body>

<form id="myform"  method="post" action="#')">
	<textarea rows="5" cols="25">初始值</textarea>
</form>


<script>

function getSelectedText(textbox){
	if (typeof textbox.selectionStart == "number"){
		return textbox.value.substring(textbox.selectionStart, 
				textbox.selectionEnd);                
	} else if (document.selection){
		return document.selection.createRange().text;
	}
}

var form = document.getElementById("myform");
var field1 = form.elements[0];
field1.onselect = function(){
	alert(getSelectedText(this));
	
}
                          



</script>

</body>
</html>
